@extends('admin::layouts.master')
@section('content')
    @component('components.tabs',['title'=>'['.$role->title.']'.'权限管理'])
        @slot('nav')
            <li class="nav-item"><a class="nav-link" href="/admin/role">角色管理</a></li>
            <li class="nav-item"><a class="nav-link active" data-toggle="modal" data-target="#addRole" href="#profile1">权限设置</a></li>
        @endslot
        @slot('content')
            <form action="/admin/role/permission/{{$role['id']}}}" method="post">
                @csrf
                <div class="card">
                    @foreach($modules as $module)
                        <div class="card-body p-0">
                            @foreach($module['rules'] as $rule)
                                <div class="card card-flat">
                                    <div class="card-header pb-0">{{ $rule['group'] }}</div>
                                    <div class="card-body p-0">
                                        <div class="col-12 col-sm-8 col-lg-6 form-check mt-1">

                                            @foreach($rule['permissions'] as $permission)
                                                <label class="custom-control custom-checkbox custom-control-inline">
                                                    <input class="custom-control-input" type="checkbox"
                                                           {{$role->hasPermissionTo($permission['name']) ? 'checked=""':''}}}
                                                           name="name[]" value="{{$permission['name']}}" >
                                                    <div class="custom-control-label">{{ $permission['title'] }}</div>
                                                </label>
                                            @endforeach

                                        </div>
                                    </div>
                                </div>
                            @endforeach
                        </div>
                    @endforeach
                </div>
                <button class="btn btn-success" type="submit">保存</button>
            </form>
        @endslot
    @endcomponent
@endsection
